<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>
Bugzilla::Install::Util</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" title="style" type="text/css" href="../.././../../../style.css" media="all" >

</head>
  <body id="pod">
<p class="backlinktop"><b><a name="___top" href="../../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
<h1>Bugzilla::Install::Util</h1>
<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <li class='indexItem indexItem1'><a href='#SUBROUTINES'>SUBROUTINES</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>Bugzilla::Install::Util - Utility functions that are useful both during installation and afterwards.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>This module contains various subroutines that are used primarily during installation.
However,
these subroutines can also be useful to non-installation code,
so they have been split out into this module.</p>

<p>The difference between this module and <a href="../../Bugzilla/Util.html" class="podlinkpod"
>Bugzilla::Util</a> is that this module is safe to <code  class="code">use</code> anywhere in Bugzilla,
even during installation,
because it depends only on <a href="../../Bugzilla/Constants.html" class="podlinkpod"
>Bugzilla::Constants</a> and built-in perl modules.</p>

<p>None of the subroutines are exported by default--you must explicitly export them.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SUBROUTINES"
>SUBROUTINES</a></h1>

<dl>
<dt><a name="bin_loc"
><code  class="code">bin_loc</code></a></dt>

<dd>
<p>On *nix systems,
given the name of a binary,
returns the path to that binary,
if the binary is in the <code  class="code">PATH</code>.</p>

<dt><a name="get_version_and_os"
><code  class="code">get_version_and_os</code></a></dt>

<dd>
<p>Returns a hash containing information about what version of Bugzilla we&#39;re running,
what perl version we&#39;re using,
and what OS we&#39;re running on.</p>

<dt><a name="get_console_locale"
><code  class="code">get_console_locale</code></a></dt>

<dd>
<p>Returns the language to use based on the LC_CTYPE value returned by the OS.
If LC_CTYPE is of the form fr-CH,
then fr is appended to the list.</p>

<dt><a name="init_console"
><code  class="code">init_console</code></a></dt>

<dd>
<p>Sets the <code  class="code">ANSI_COLORS_DISABLED</code> and <code  class="code">HTTP_ACCEPT_LANGUAGE</code> environment variables.</p>

<dt><a name="indicate_progress"
><code  class="code">indicate_progress</code></a></dt>

<dd>
<dl>
<dt><a name="Description"
><b>Description</b></a></dt>

<dd>
<p>This prints out lines of dots as a long update is going on,
to let the user know where we are and that we&#39;re not frozen.
A new line of dots will start every 60 dots.</p>

<p>Sample usage: <code  class="code">indicate_progress({ total =&#62; $total,
current =&#62; $count,
every =&#62; 1 })</code></p>

<dt><a name="Sample_Output"
><b>Sample Output</b></a></dt>

<dd>
<p>Here&#39;s some sample output with <code  class="code">total = 1000</code> and <code  class="code">every = 10</code>:</p>

<pre  class="code"> ............................................................600/1000 (60%)
 ........................................</pre>

<dt><a name="Params"
><b>Params</b></a></dt>

<dd>
<dl>
<dt><a name="total_-_The_total_number_of_items_we&#39;re_processing."
><code  class="code">total</code> - The total number of items we&#39;re processing.</a></dt>

<dd>
<dt><a name="current_-_The_number_of_the_current_item_we&#39;re_processing."
><code  class="code">current</code> - The number of the current item we&#39;re processing.</a></dt>

<dd>
<dt><a 
><code  class="code">every</code> - How often the function should print out a dot. For example, if this is 10, the function will print out a dot every ten items. Defaults to 1 if not specified.</a></dt>
</dl>

<dt><a name="Returns:_nothing"
><b>Returns</b>: nothing</a></dt>
</dl>

<dt><a name="install_string"
><code  class="code">install_string</code></a></dt>

<dd>
<dl>
<dt><a name="Description"
><b>Description</b></a></dt>

<dd>
<p>This is a very simple method of templating strings for installation. It should only be used by code that has to run before the Template Toolkit can be used. (See the comments at the top of the various <a href="../../Bugzilla/Install.html" class="podlinkpod"
>Bugzilla::Install</a> modules to find out when it&#39;s safe to use Template Toolkit.)</p>

<p>It pulls strings out of the <em  class="code">strings.txt.pl</em> &#34;template&#34; and replaces any variable surrounded by double-hashes (##) with a value you specify.</p>

<p>This allows for localization of strings used during installation.</p>

<dt><a name="Example"
><b>Example</b></a></dt>

<dd>
<p>Let&#39;s say your template string looks like this:</p>

<pre  class="code"> The ##animal## jumped over the ##plant##.</pre>

<p>Let&#39;s say that string is called &#39;animal_jump_plant&#39;. So you call the function like this:</p>

<pre  class="code"> install_string(&#39;animal_jump_plant&#39;, { animal =&#62; &#39;fox&#39;, plant =&#62; &#39;tree&#39; });</pre>

<p>That will output this:</p>

<pre  class="code"> The fox jumped over the tree.</pre>

<dt><a name="Params"
><b>Params</b></a></dt>

<dd>
<dl>
<dt><a name="$string_id_-_The_name_of_the_string_from_strings.txt.pl."
><code  class="code">$string_id</code> - The name of the string from <em  class="code">strings.txt.pl</em>.</a></dt>

<dd>
<dt><a name="$vars_-_A_hashref_containing_the_replacement_values_for_variables_inside_of_the_string."
><code  class="code">$vars</code> - A hashref containing the replacement values for variables inside of the string.</a></dt>
</dl>

<dt><a name="Returns:_The_appropriate_string,_with_variables_replaced."
><b>Returns</b>: The appropriate string, with variables replaced.</a></dt>
</dl>

<dt><a name="template_include_path"
><code  class="code">template_include_path</code></a></dt>

<dd>
<p>Used by <a href="../../Bugzilla/Template.html" class="podlinkpod"
>Bugzilla::Template</a> and <a href="#install_string" class="podlinkpod"
>&#34;install_string&#34;</a> to determine the directories where templates are installed. Templates can be installed in many places. They&#39;re listed here in the basic order that they&#39;re searched:</p>

<dl>
<dt><a name="extensions/$extension/template/$language/$project"
>extensions/<code  class="code">$extension</code>/template/<code  class="code">$language</code>/<code  class="code">$project</code></a></dt>

<dd>
<dt><a name="extensions/$extension/template/$language/custom"
>extensions/<code  class="code">$extension</code>/template/<code  class="code">$language</code>/custom</a></dt>

<dd>
<dt><a name="extensions/$extension/template/$language/default"
>extensions/<code  class="code">$extension</code>/template/<code  class="code">$language</code>/default</a></dt>

<dd>
<dt><a name="template/$language/$project"
>template/<code  class="code">$language</code>/<code  class="code">$project</code></a></dt>

<dd>
<dt><a name="template/$language/custom"
>template/<code  class="code">$language</code>/custom</a></dt>

<dd>
<dt><a name="template/$language/default"
>template/<code  class="code">$language</code>/default</a></dt>
</dl>

<p><code  class="code">$project</code> has to do with installations that are using the <code  class="code">$ENV{PROJECT}</code> variable to have different &#34;views&#34; on a single Bugzilla.</p>

<p>The <em  class="code">default</em> directory includes templates shipped with Bugzilla.</p>

<p>The <em  class="code">custom</em> directory is a directory for local installations to override the <em  class="code">default</em> templates. Any individual template in <em  class="code">custom</em> will override a template of the same name and path in <em  class="code">default</em>.</p>

<p><code  class="code">$language</code> is a language code, <code  class="code">en</code> being the default language shipped with Bugzilla. Localizers ship other languages.</p>

<p><code  class="code">$extension</code> is the name of any directory in the <em  class="code">extensions/</em> directory. Each extension has its own directory.</p>

<p>Note that languages are sorted by the user&#39;s preference (as specified in their browser, usually), and extensions are sorted alphabetically.</p>

<dt><a name="include_languages"
><code  class="code">include_languages</code></a></dt>

<dd>
<p>Used by <a href="../../Bugzilla/Template.html" class="podlinkpod"
>Bugzilla::Template</a> to determine the languages&#39; list which are compiled with the browser&#39;s <i>Accept-Language</i> and the languages of installed templates.</p>

<dt><a name="vers_cmp"
><code  class="code">vers_cmp</code></a></dt>

<dd>
<dl>
<dt><a name="Description"
><b>Description</b></a></dt>

<dd>
<p>This is a comparison function, like you would use in <code  class="code">sort</code>, except that it compares two version numbers. So, for example, 2.10 would be greater than 2.2.</p>

<p>It&#39;s based on versioncmp from <a href="../../Sort/Versions.html" class="podlinkpod"
>Sort::Versions</a>, with some Bugzilla-specific fixes.</p>

<dt><a name="Params:_$a_and_$b_-_The_versions_you_want_to_compare."
><b>Params</b>: <code  class="code">$a</code> and <code  class="code">$b</code> - The versions you want to compare.</a></dt>

<dd>
<dt><a name="Returns"
><b>Returns</b></a></dt>

<dd>
<p><code  class="code">-1</code> if <code  class="code">$a</code> is less than <code  class="code">$b</code>, <code  class="code">0</code> if they are equal, or <code  class="code">1</code> if <code  class="code">$a</code> is greater than <code  class="code">$b</code>.</p>
</dd>
</dl>
</dd>
</dl>
<p class="backlinkbottom"><b><a name="___bottom" href="../../index.html" title="All Documents">&lt;&lt;</a></b></p>

<!-- end doc -->

</body></html>
